<%--
  Created by IntelliJ IDEA.
  User: 范军建
  Date: 2022/4/14
  Time: 18:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path =request.getContextPath();
%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    function deng(event) {

        event.preventDefault()
        var username= document.getElementById("username").value;
        var password = document.getElementById("password").value;
        var url="chakan?username="+username+"&password=" +password;
        var ajz  =  new XMLHttpRequest();

        ajz.open("post",url,true);
        ajz.send();
        ajz.onreadystatechange=callBack;
        function callBack() {
            console.log(ajz)
            if(ajz.readyState==4 && ajz.status==200){
                var txt = ajz.responseText;
                if(txt==1){
                    alert("查询成功");
                    var path=document.getElementById("path").value;
                    window.location.href=path+"/index2.jsp"
                }else {
                    alert("查询失败")
                }
            }
        }
    }

</script>

<div style="margin: 0px;display: flex; justify-content: center;margin-top: 300px;">
    <form  method="post" style="line-height: 50px">
        <input type="text" id="username">用户名<br>
        <input type="text" id="password">密码<br>
        <%--<%
        String username=request.getParameter("username");
        String password=request.getParameter("password");
        %>--%>
        <%--<a href="#" onclick="cha()">登录查询</a>--%>
        <input type="submit" onclick="deng(event)">
        <%--//<input type="submit" value="登录查询" style="margin-left: 60px">--%>
        <input type="hidden" id="path" value="<%=path%> "style="margin-left: 60px">
    </form>
    </div>

</body>
</html>
